import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class VentanaEstados extends JFrame implements ActionListener{

	private static final long serialVersionUID = 1L;
	private JPanel Panel;
	private JLabel text;
	public JTextField sensor1;
	public JTextField sensor2;
	public JTextField sensor3;
	public JTextField sensor4;
	public JTextField sensor5;
	public JTextField sensor6;
	public JTextField sensor7;
	public JTextField sensor8;
	public JTextField sensor9;
	public JTextField sensor10;	
	private JButton cerrar;
	
	public VentanaEstados(boolean modo, String sensor){
		
		//ASPECTOS GENERALES DE LA VENTANA
		this.setResizable(false);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		if(modo==true){
			this.setSize(new Dimension(330, 575));			
			this.setTitle("ESTADO DE LOS SENSORES");
		}else{
			this.setSize(new Dimension(330, 380));
			this.setTitle("HISTORICO SENSOR");
		}		
		
		//ELEMENTOS VISUALES DE LA VENTANA
        Panel = new JPanel();
        Panel.setLayout(null);       
        sensor1 = new JTextField();
		sensor1.setBounds(new Rectangle(30, 80, 250, 25));
		sensor1.setEnabled(false);
		Panel.add(sensor1, null);
		sensor2 = new JTextField();
		sensor2.setBounds(new Rectangle(30, 120, 250, 25));
		sensor2.setEnabled(false);
		Panel.add(sensor2, null);
		sensor3 = new JTextField();
		sensor3.setBounds(new Rectangle(30, 160, 250, 25));
		sensor3.setEnabled(false);
		Panel.add(sensor3, null);
		sensor4 = new JTextField();
		sensor4.setBounds(new Rectangle(30, 200, 250, 25));
		sensor4.setEnabled(false);
		Panel.add(sensor4, null);
		sensor5 = new JTextField();
		sensor5.setBounds(new Rectangle(30, 240, 250, 25));
		sensor5.setEnabled(false);
		Panel.add(sensor5, null);
		cerrar = new JButton();
		cerrar.setText("CERRAR");
		if(modo==true){
			text = new JLabel();
	        text.setBounds(new Rectangle(30, 40, 300, 30));
	        text.setText("Listado del estado de los 10 sensores del tren:");
	        Panel.add(text, null);	
			sensor6 = new JTextField();
			sensor6.setBounds(new Rectangle(30, 280, 250, 25));
			sensor6.setEnabled(false);
			Panel.add(sensor6, null);
			sensor7 = new JTextField();
			sensor7.setBounds(new Rectangle(30, 320, 250, 25));
			sensor7.setEnabled(false);
			Panel.add(sensor7, null);
			sensor8 = new JTextField();
			sensor8.setBounds(new Rectangle(30, 360, 250, 25));
			sensor8.setEnabled(false);
			Panel.add(sensor8, null);
			sensor9 = new JTextField();
			sensor9.setBounds(new Rectangle(30, 400, 250, 25));
			sensor9.setEnabled(false);
			Panel.add(sensor9, null);
			sensor10 = new JTextField();
			sensor10.setBounds(new Rectangle(30, 440, 250, 25));
			sensor10.setEnabled(false);
			Panel.add(sensor10, null);
			cerrar.setBounds(new Rectangle(110, 500, 110, 25));
		}else{
			text = new JLabel();
	        text.setBounds(new Rectangle(30, 40, 300, 30));
	        text.setText("Listado del historico del sensor "+sensor+":");
	        Panel.add(text, null);
			cerrar.setBounds(new Rectangle(110, 300, 110, 25));		
		}	
		Panel.add(cerrar, null);
		this.setContentPane(Panel);
		
		//ACTION LISTENER
		cerrar.addActionListener(this);
	}
	
	public void actionPerformed(ActionEvent arg0){
		if(arg0.getSource()==cerrar){
			this.dispose();
		}
	}
	
	public static void main(String [] args){
		VentanaEstados vE = new VentanaEstados(true, "0");
		vE.setVisible(true);
	}
}
